<!DOCTYPE html>
<!-- 岗位详细信息 -->
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <title>岗位详细信息</title>
    <link rel="stylesheet" href="../../css/main.css" media="all">
    <link rel="stylesheet" href="../../css/jobDetail.css" media="all">
    <style type="text/css">
        pre {
            white-space: pre-wrap;
            white-space: -moz-pre-wrap;
            white-space: -pre-wrap;
            white-space: -o-pre-wrap;
            word-wrap: break-word;
        }
    </style>
    <!-- 岗位顶部模板   -->
    <script id="tpl_detail_head" type="text/html">
        <div class="layui-col-md4">
            <h1>{{d.jobname}}</h1>
        </div>
        <div class="layui-col-md3" style="margin:0 auto;text-align:center;">
            <span class="salary">{{d.jobsalary}}</span>
        </div>
    </script>
    <!-- 福利标签模板   -->
    <script id="tpl_job_welfare" type="text/html">
        {{#  layui.each(d.list, function(index, item){ }}
        <span>{{item}}</span>
        {{#  }); }}

        {{#  if(d.list.length === 0){ }}
        <span>无</span>
        {{#  } }}
    </script>
    <!-- 职位描述模板   -->
    <script id="tpl_job_content" type="text/html">
        <div class="layui-row" style="margin-top:20px">
            <div class="layui-card">
                <div class="layui-card-header">
                    <h2>职位描述</h2>
                </div>
                <div class="layui-card-body job_sy_color">
                    <pre>{{d.descriptionofjob}}</pre>
                </div>
            </div>
        </div>
        <div class="layui-row" style="margin-top:20px">
            <div class="layui-card">
                <div class="layui-card-header">
                    <h2>岗位要求</h2>
                </div>
                <div class="layui-card-body job_sy_color">
                    <pre>{{d.jobrequirement}}</pre>
                </div>
            </div>
        </div>
        <div class="layui-row" style="margin-top:20px">
            <div class="layui-card">
                <div class="layui-card-header">
                    <h2 style="width: 50%; float: left;">公司介绍</h2>
                    <h3 style="float:right;color: royalblue;"><a style="color:royalblue;"
                                                                 href="viewenterpriseinfo.html?eid={{d.enterprise.enterpriseid}}">详细信息</a>
                    </h3>
                </div>
                <div class="layui-card-body job_sy_color">
                    {{d.enterprise.authInfomation.companyprofile}}
                </div>
            </div>
        </div>

        <div class="layui-row" style="margin-top:20px">
            <div class="layui-card">
                <div class="layui-card-header">
                    <h2>工作地址</h2>
                </div>
                <div class="layui-card-body job_sy_color">
                    <p>{{d.workplace}}</p>
                </div>
            </div>
        </div>
        <div class="layui-row" style="margin-top:20px">
            <div class="layui-card">
                <div class="layui-card-header">
                    <h3>推荐职位</h3>
                </div>
                <div class="layui-card-body job_sy_color" style="border:1px #e3e7ed solid" id="dta_recommendedPosition">
                    <div class="layui-row" style="margin-top:20px">
                        <a href="">
                            <div class="layui-col-md3 job_rocm ">
                                <h3> 会计实习生</h3>
                            </div>
                            <div class="layui-col-md3 job_rocm ">
                                云南财当家
                            </div>
                            <div class="layui-col-md3 job_rocm ">
                                <span style="color: red;"> 20-50K</span>
                            </div>
                        </a>
                    </div>
                    <div class="layui-row" style="margin-top:20px">
                        <a href="">
                            <div class="layui-col-md3 job_rocm ">
                                <h3> 会计实习生</h3>
                            </div>
                            <div class="layui-col-md3 job_rocm ">
                                云南财当家
                            </div>
                            <div class="layui-col-md3 job_rocm ">
                                <span style="color: red;"> 20-50K</span>
                            </div>
                        </a>
                    </div>
                    <div class="layui-row" style="margin-top:20px">
                        <a href="">
                            <div class="layui-col-md3 job_rocm ">
                                <h3> 会计实习生</h3>
                            </div>
                            <div class="layui-col-md3 job_rocm ">
                                云南财当家
                            </div>
                            <div class="layui-col-md3 job_rocm ">
                                <span style="color: red;"> 20-50K</span>
                            </div>
                        </a>
                    </div>
                    <div class="layui-row" style="margin-top:20px">
                        <a href="">
                            <div class="layui-col-md3 job_rocm ">
                                <h3> 会计实习生</h3>
                            </div>
                            <div class="layui-col-md3 job_rocm ">
                                云南财当家
                            </div>
                            <div class="layui-col-md3 job_rocm ">
                                <span style="color: red;"> 20-50K</span>
                            </div>
                        </a>
                    </div>
                    <div class="layui-row" style="margin-top:20px">
                        <a href="">
                            <div class="layui-col-md3 job_rocm ">
                                <h3> 会计实习生</h3>
                            </div>
                            <div class="layui-col-md3 job_rocm ">
                                云南财当家
                            </div>
                            <div class="layui-col-md3 job_rocm ">
                                <span style="color: #fc703e;"> 20-50K</span>
                            </div>

                        </a>
                    </div>
                </div>
            </div>
        </div>
    </script>
    <!--  右侧企业信息  -->
    <script id="tpl_company" type="text/html">
        <div class="layui-card-header">
            <a href="viewenterpriseinfo.html?eid={{d.enterpriseid}}"><h2>{{d.enterprisename}}</h2></a>
        </div>
        <div class="layui-card-body job_sy_color">
            <p><i class="icon-stage"></i>{{d.authInfomation.enterprisetype}}</p>
            <p><i class="icon-scale"></i>{{d.authInfomation.scale}}</p>
            <p><i class="icon-industry"></i>{{d.authInfomation.industry}}</p>
        </div>
    </script>
    <!--  相似职位  -->
    <script id="tpl_similarPosition" type="text/html">
        {{#  layui.each(d.list, function(index, item){ }}
        <div class="e">
            <a class="name" target="_blank" href="jobDetail.html?jobid={{item.jobid}}" title="{{item.jobname}}">{{item.jobname}}</a>
            <a>{{item.jobType.typename}}</a>
            <strong title="{{item.jobsalary}}">{{item.jobsalary}}</strong>
            <span title="{{item.workplace}}">{{item.workplace}}</span>
        </div>
        {{#  }); }}

        {{#  if(d.list.length === 0){ }}
        <div class="e">
            暂无相似职位
        </div>
        {{#  } }}

    </script>
    <!-- 推荐职位   -->
    <script id="tpl_recommendedPosition" type="text/html">
        {{#  layui.each(d.list, function(index, item){ }}
        <div class="layui-row" style="margin-top:20px">
            <a href="javascript:;" onclick="window.open('jobDetail.html?jobid={{item.jobid}}', '_top', '', 'false');">
                <div class="layui-col-md3 job_rocm ">
                    <h3>{{item.jobname}}</h3>
                </div>
                <div class="layui-col-md3 job_rocm ">
                    {{item.enterprise.enterprisename}}
                </div>
                <div class="layui-col-md3 job_rocm ">
                    <span style="color: red;">{{item.jobsalary}}</span>
                </div>
            </a>
        </div>
        {{#  }); }}

        {{#  if(d.list.length === 0){ }}
        <div class="layui-row" style="margin-top:20px">
            暂无推荐职位
        </div>
        {{#  } }}
    </script>
</head>

<body>
<div id="LAY_app">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <!-- 测试测试   -->
            <div class="layui-col-xs1 layui-col-sm1 layui-col-md1">&nbsp;</div>
            <!-- 头部区域 -->
            <div class="layui-col-xs4 layui-col-sm6 layui-col-md6">
                <div style="display:inline-block;margin-left: 20px;">
                    <img id="logimage" src="../../image/logo.png" height="50px" style="padding-top: 5px;cursor:pointer"
                         title="首页"
                         onclick="window.open('index.html', '_top', '', 'true')">
                </div>
            </div>

            <div class="layui-col-xs6 layui-col-sm4 layui-col-md4">
                <ul class="layui-nav" align="right" lay-filter="layadmin-layout-right">
                    <li class="layui-nav-item" lay-unselect>
                        <a id="icon-btn" href="javascript:;">
                            <img id="stuimg" src="../../image/avatar.png" class="layui-nav-img">
                            <cite id="stuname">贤心</cite>
                        </a>
                        <dl class="layui-nav-child">
                            <dd id="viewinfo"><a>基本资料</a></dd>
                            <dd id="changepwd"><a>修改密码</a></dd>
                            <hr>
                            <dd id="logout" style="text-align: center;"><a>退出</a></dd>
                        </dl>
                    </li>

                    <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-unselect>
                        <a href="javascript:;" layadmin-event="more"><i class="layui-icon layui-icon-more-vertical"></i></a>
                    </li>
                </ul>
            </div>
            <div class="layui-col-xs1 layui-col-sm1 layui-col-md1">&nbsp;</div>
        </div>
    </div>
</div>
<!-- 导航栏end -->
<!-- 岗位基础 -->
<div class="layui-container-md job_synopsis">
    <div class="layui-row">
        <div class="layui-col-md1">&nbsp;</div>
        <div class="layui-col-xs4 layui-col-sm7 layui-col-md7  inner_content_left">
            <div class="layui-row job_name" id="dta_jobHead">
                <!--    职位顶部渲染数据部分     -->
            </div>

            <div class="layui-row job_welfare">
                <div class="tag_more"></div>
                <div class="tag-all job-tags" id="dta_job_welfare">
                    <!--  公司福利标签渲染   -->
                </div>
            </div>
        </div>
        <div class="layui-col-md3 layui-col-xs2 layui-col-sm5 layui-hide-xs inner_content_right">

            <button type="button" id="addnotebook" class="layui-btn layui-btn-fluid"
                    style="background-color: salmon;">
                立即申请
            </button>
        </div>
        <!-- <div class="layui-row">
          <div class="layui-col-md3">
            <button type="button" class="layui-btn  layui-btn-sm"  style="background-color: salmon;">填写在线简历</button>
          </div>
          <div class="layui-col-md3" style="margin-left: 50px;">
            <button type="button" class="layui-btn layui-btn-sm"  style="background-color: salmon;">上传附件简历</button>
          </div>
        </div> -->
    </div>
    <div class="layui-col-md1">&nbsp;</div>
</div>
<!-- 岗位基础end -->
<!-- 职位详细 -->
<div class="layui-container-md ">
    <div class="layui-row">
        <div class="layui-col-md9" style="border-right:3px solid #f2f5fa;">
            <div class="layui-col-md1">&nbsp;</div>
            <!-- 左侧详细 -->
            <div class="layui-col-xs4 layui-col-sm7 layui-col-md9  inner_content_left" id="dta_job_content">
                <!--    职位详细渲染数据部分            -->
            </div>
            <!-- 左侧详细end -->
        </div>
        <!-- 右侧开始-->
        <div class="layui-col-md3 inner_content_right">
            <div class="layui-row" style="margin-top:20px">
                <div class="layui-card" style="border:1px #e3e7ed solid;color: #8d92a1;background: #f6f6f8"
                     id="dta_company">
                    <!--   右侧公司信息  -->
                </div>
            </div>
            <div class="layui-row promotion-job" style="margin-top:20px">
                <div class="layui-card" style="border:1px #e3e7ed solid;color: #8d92a1;background: #f6f6f8">
                    <div class="layui-card-header">
                        <h2>相似职位</h2>
                    </div>
                    <div class="layui-card-body rjlist r3" id="dta_similarPosition">
                        <div class="e">
                            <a class="name" target="_blank" href=" " title="消防中控员">消防中控员</a>
                            <a target="_blank" href=" " title="昆明万博吾悦商业管理有限公司">昆明万博吾悦商业管理有限公司</a>
                            <strong title="4.5-6千/月">4.5-6千/月</strong>
                            <span title="昆明-呈贡区">昆明-呈贡区</span>
                            <em class="apply" name="delivery_em" onclick="emClick(this)"></em>
                            <input class="checkbox" type="checkbox" name="delivery_jobid_similar" value="121507520"
                                   style="display:none" jt="2">
                        </div>
                        <div class="e">
                            <a class="name" target="_blank" href=" " title="消防中控员">消防中控员</a>
                            <a target="_blank" href=" " title="昆明万博吾悦商业管理有限公司">昆明万博吾悦商业管理有限公司</a>
                            <strong title="4.5-6千/月">4.5-6千/月</strong>
                            <span title="昆明-呈贡区">昆明-呈贡区</span>
                            <em class="apply" name="delivery_em" onclick="emClick(this)"></em>
                            <input class="checkbox" type="checkbox" name="delivery_jobid_similar" value="121507520"
                                   style="display:none" jt="2">
                        </div>
                        <div class="e">
                            <a class="name" target="_blank" href=" " title="消防中控员">消防中控员</a>
                            <a target="_blank" href=" " title="昆明万博吾悦商业管理有限公司">昆明万博吾悦商业管理有限公司</a>
                            <strong title="4.5-6千/月">4.5-6千/月</strong>
                            <span title="昆明-呈贡区">昆明-呈贡区</span>
                            <em class="apply" name="delivery_em" onclick="emClick(this)"></em>
                            <input class="checkbox" type="checkbox" name="delivery_jobid_similar" value="121507520"
                                   style="display:none" jt="2">
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <!-- 右侧结束-->
</div>
<script src="../../libs/layui/layui.js"></script>
<script src="../../js/header.js"></script>
<script>
    layui.use(['element', 'layer', 'jquery', 'laytpl', 'okLayer'], function () {
        let element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
        let layer = layui.layer;
        let $ = layui.jquery;
        let laytpl = layui.laytpl;
        let okLayer = layui.okLayer;
        //监听导航点击
        element.on('nav(demo)', function (elem) {
            // console.log(elem)
            layer.msg(elem.text());
        });
        let jobid = window.location.href.split("?")[1].split("=")[1];
        // 获取contentText
        const ctx = function () {
            let pathName = document.location.pathname;
            let index = pathName.substr(1).indexOf("/");
            let result = pathName.substr(0, index + 1);
            return result;
        }();


        // 获取student
        var student = JSON.parse(window.sessionStorage.getItem("student"));
        var url = ctx + "/pages/student/studentLogin.html";
        if (student == null) {
            okLayer.yellowSighMsg("登陆时间超时，请重新登录！", function () {
                window.sessionStorage.clear();
                window.open(url, "_top", "", "true");
            });
        }
        //退出登录
        $("#logout").bind('click', function () {
            window.sessionStorage.clear();
            window.open(url, "_top", "", "true");
        })
        //个人信息
        $("#viewinfo").bind('click', function () {
            let vurl = ctx + "/pages/student/studentindex.html";
            window.open(vurl, "_top", "", "true");
        })
        //忘记密码
        $("#changepwd").bind('click', function () {
            let curl = ctx + "/pages/student/stuForget.html";
            window.open(curl, "_top", "", "true");
        })
        $("#icon-btn").bind('click', function () {
            let vurl = ctx + "/pages/student/studentindex.html";
            window.open(vurl, "_top", "", "true");
        })
        stateDetection();
        //得到模板样式
        var tplHead = document.getElementById('tpl_detail_head').innerHTML;
        var tplcontent = document.getElementById('tpl_job_content').innerHTML;
        var tplwelfare = document.getElementById('tpl_job_welfare').innerHTML;
        var tplcompany = document.getElementById('tpl_company').innerHTML;
        //数据渲染
        $.ajax({
            //请求地址
            url: ctx + "/ygssecs/getjobdetailbyid",
            //请求方式
            type: "get",
            data: {jobid: jobid},
            //数据，json字符串
            dataType: "JSON",
            beforeSend: function () {
                layer.load();
            },
            //请求成功
            success: function (result) {
                console.log(result);
                layer.closeAll();
                if (result.code == 200) {
                    var jobdata = result.data;
                    var jobtype = jobdata.jobType.typename;
                    loadsimilarPosition(jobtype);
                    //渲染头部
                    laytpl(tplHead).render(result.data, function (html) {
                        document.getElementById('dta_jobHead').innerHTML = html;
                    });
                    //头部渲染结束
                    //公司福利渲染
                    var welfarestr = jobdata.corporatebenefits;
                    var welfarearr = new Array();
                    welfarearr = welfarestr.split(",");
                    var welfaredata = {
                        "title": "福利",
                        "list": welfarearr
                    }
                    laytpl(tplwelfare).render(welfaredata, function (html) {
                        document.getElementById('dta_job_welfare').innerHTML = html;
                        // layer.msg('数据渲染成功', {icon: 1, time: 2000});
                    });
                    //公司福利结束
                    //渲染岗位数据
                    laytpl(tplcontent).render(jobdata, function (html) {
                        document.getElementById('dta_job_content').innerHTML = html;
                        // layer.msg('数据渲染成功', {icon: 1, time: 2000});
                    });
                    recommendedPosition();
                    //岗位数据结束
                    //渲染右侧公司数据
                    var companydata = jobdata.enterprise;
                    jobtypename = jobdata.jobType.typename;
                    laytpl(tplcompany).render(companydata, function (html) {
                        document.getElementById('dta_company').innerHTML = html;
                    })
                }
            },
            //请求失败，包含具体的错误信息
            error: function (e) {
                console.log(e.status);
                console.log(e.responseText);
                layer.msg('数据请求失败', {
                    icon: 5,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                }, function () {
                    location.reload()
                });
            }
        });

        //申请按钮触发事件
        $('#addnotebook').on("click", function () {
            layer.open({
                //调整弹框的大小
                title: ["留言", ' text-align: center;'],
                area: ['600px', '250px'],
                shadeClose: true,//点击旁边地方自动关闭
                //动画
                anim: 2,
                //弹出层的基本类型
                type: 2,
                //刚才定义的弹窗页面
                content: ['leavingMsg.html', 'no'],//这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
                success: function (layero) {
                    let iframeWin = window[layero.find("iframe")[0]["name"]];
                    iframeWin.initjobid(jobid);
                }, end: function () {
                    location.reload();
                }
            });
        });

        //申请状态检测
        function stateDetection() {
            $.ajax({
                url: ctx + '/ygssecs/detectionpostionStatus',
                type: 'get',
                data: {jobid: jobid, stuid: student.stuid},
                dataType: 'json'
            }).done(function (res) {
                if (res.code == 200) {
                    if (res.status == "1") {
                        $("#addnotebook").attr("disabled", 'disabled');
                        $("#addnotebook").text("已申请此岗位");
                    } else {
                        $("#addnotebook").removeAttr("disabled")
                        $("#addnotebook").text("立即申请");
                    }
                }
            }).fail(function (error) {
                console.error(error)
            })
        }

        //加载相似岗位
        function loadsimilarPosition(jobtype) {
            var tplsimilarPosition = document.getElementById("tpl_similarPosition").innerHTML;
            $.ajax({
                url: ctx + '/ygssecs/similarPosition',
                type: 'get',
                data: {jobtype: jobtype},
                dataType: 'json'
            }).done(function (res) {
                laytpl(tplsimilarPosition).render(res.data, function (html) {
                    document.getElementById("dta_similarPosition").innerHTML = html;
                })
            }).fail(function (error) {
                console.error(error)
            })
        }

        //加载推荐岗位
        function recommendedPosition() {
            var tplrecommendedPosition = document.getElementById("tpl_recommendedPosition").innerHTML;
            //渲染推荐岗位
            $.ajax({
                url: ctx + '/ygssecs/getRecommendjoblist',
                type: 'get',
                data: {postionnum: 5},
                dataType: 'json'
            }).done(function (res) {
                if (res.code == 200) {
                    laytpl(tplrecommendedPosition).render(res.data, function (html) {
                        document.getElementById("dta_recommendedPosition").innerHTML = html;
                    })
                }
            }).fail(function (error) {
                console.error(error)
            })
        }
    });
</script>
</body>

</html>